// 校验手机号或固话
export const validate_telephone = function(value, errorMsg) {
	if (/^1\d{10}$/.test(value) || /^([0-9]{3,4}-)?[0-9]{7,8}$/.test(value)) return true;
	if (errorMsg) {
		uni.showToast({
			icon: 'none',
			title: errorMsg
		});
	}
	return false;
}

// 匹配参数
export const getQueryParam = (url, param) => {
	const name = param.replace(/[[]]/g, '\\[').replace(/[]]/g, '\\]');
	const regex = new RegExp('[&?]?' + name + '(=([^&#]*)|&|#|$)');
	const results = regex.exec(url);

	if (!results) return null;
	if (!results[2]) return '';
	return decodeURIComponent(results[2].replace(/\+/g, ' '));
}